import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CodeVO, CodeForm, CodeQuery } from '@/apillm/code/types';

/**
 * 查询激活码列表
 * @param query
 * @returns {*}
 */

export const listCode = (query?: CodeQuery): AxiosPromise<CodeVO[]> => {
  return request({
    url: '/llm/code/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询激活码详细
 * @param id
 */
export const getCode = (id: string | number): AxiosPromise<CodeVO> => {
  return request({
    url: 'llm/code/' + id,
    method: 'get'
  });
};

/**
 * 新增激活码
 * @param data
 */
export const addCode = (data: CodeForm) => {
  return request({
    url: '/llm/code',
    method: 'post',
    data: data
  });
};

/**
 * 新增激活码
 * @param data
 */
export const generate = () => {
  return request({
    url: 'llm/code/generate',
    method: 'post'
  });
};

/**
 * 修改激活码
 * @param data
 */
export const updateCode = (data: CodeForm) => {
  return request({
    url: '/llm/code',
    method: 'put',
    data: data
  });
};

/**
 * 删除激活码
 * @param id
 */
export const delCode = (id: string | number | Array<string | number>) => {
  return request({
    url: 'llm/code/' + id,
    method: 'delete'
  });
};
